#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const int mod = 998244353;
const int inv2 = (mod + 1) >> 1;
ll n; int m;
int p, q;
int a[maxn];
map<int, int> mp;
int b[maxn], c[maxn]; int len = 0;
__int128 getc2(ll x){
    return (__int128)(x) * (x - 1) / 2;
}
int qpow(int x, __int128 y){
    int res = 1; x %= mod;
    while(y){
	if(y & 1) res = 1ll * res * x % mod;
	x = 1ll * x * x % mod; y >>= 1;
    }
    return res;
}
void upd(int &x, int y){
    return x = x + y >= mod ? x + y - mod : x + y, void();
}
int ans = 0;
void dfs(int st, ll now, int pm){
    if(pm == 0) return ;
    if(st == len + 1){
	__int128 px = now;
	__int128 py = (__int128)((n / now) / 2) * (now) + getc2(now) * (n / now);
	upd(ans, 1ll * qpow(p, px) * qpow(q, py) % mod * pm % mod);
	// cerr << (ll)px << " " << (ll)py << " " << now << " " << pm << endl;
	if(now & 1){
	    px = (__int128)(now + 1) / 2;
	    py = (__int128)(now / 2 + 1) * ((n / now) / 2) + ((__int128)(n / now) * getc2(now) + (__int128)(now / 2) * (n / now)) / 2;
	    upd(ans, mod - 1ll * qpow(p, px) * qpow(q, py) % mod * pm % mod * (n % mod) % mod);
	    // cerr << "? " << (ll)px << " " << (ll)py << " " << 1ll * qpow(p, px) * qpow(q, py) % mod * (n % mod) % mod << endl;
	} else if(now % 2 == 0){
	    px = (__int128)(now / 2);
	    py = (__int128)(now / 2) * ((n / now) / 2) + ((__int128)(n / now) * getc2(now) + (__int128)(now / 2) * (n / now)) / 2;
	    upd(ans, mod - 1ll * qpow(p, px) * qpow(q, py) % mod * pm % mod * ((n / 2) % mod) % mod);
	    px = (__int128)(now / 2) + 1;
	    py = (__int128)(now / 2 + 1) * ((n / now) / 2) + ((__int128)(n / now) * getc2(now) + (__int128)(now / 2 - 1) * (n / now) + 1) / 2;
	    upd(ans, mod - 1ll * qpow(p, px) * qpow(q, py) % mod * pm % mod * ((n / 2) % mod) % mod);
	}
	return ;
    }
    ll ml = now;
    for(int i = 0;i <= c[st];i++){
	dfs(st + 1, ml, (c[st] - i > 1 ? 0 : (c[st] - i ? mod - pm : pm))); ml = ml * b[st];
    }
    return ;
}
int main(){
    freopen("clown.in", "r", stdin);
    freopen("clown.out", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> m; n = 1;
    for(int i = 1;i <= m;i++){
	cin >> a[i]; mp[a[i]]++;
	n = n * a[i];
    }
    cin >> p >> q;
    for(auto fr : mp){
	b[++len] = fr.first;
	c[len] = fr.second;
    }
    dfs(1, 1, 1);
    cout << ans << endl;
    return 0;
}
